#pragma once

// Only include FlexLexer.h if it hasn't been already included
#ifndef __FLEX_LEXER_H
#define yyFlexLexer MathematicaTranslatorFlexLexer
#include "FlexLexer.h"
#undef yyFlexLexer
#endif

// Windows doesn't have unistd.h and it doesn't appear to be necessary
#define YY_NO_UNISTD_H

// Override the interface for yylex since we namespaced it
#undef YY_DECL

#define	YY_DECL						\
    MathematicaTranslator::Parser::token_type				\
    MathematicaTranslator::Scanner::lex(				\
	MathematicaTranslator::Parser::semantic_type* yylval,		\
	MathematicaTranslator::Parser::location_type* yylloc		\
    )


#include "matrix_grammar.tab.hpp"


namespace MathematicaTranslator
{
	class Scanner : private MathematicaTranslatorFlexLexer
	{
	public:
		/** Create a new scanner object. The streams arg_yyin and arg_yyout default
		* to cin and cout, but that assignment is only made when initializing in
		* yylex(). */
		Scanner(std::istream* arg_yyin = 0,
			std::ostream* arg_yyout = 0);

		/** Required for virtual functions */
		virtual ~Scanner();

		/** This is the main lexing function. It is generated by flex according to
		* the macro declaration YY_DECL above. The generated bison parser then
		* calls this virtual function to fetch new tokens. */
		virtual Parser::token_type lex(
			Parser::semantic_type* yylval,
			Parser::location_type* yylloc
			);
		/** Enable debug output (via arg_yyout) if compiled into the scanner. */
		void set_debug(bool b);
	};

}
